package cn.js.servlet;

import cn.js.dao.powerbattery.SysPowerbatteryMapper;
import cn.js.pojo.Powerbattery;
import cn.js.utils.MyBatisUtil;
import org.apache.ibatis.session.SqlSession;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(urlPatterns = "/PowerBatteryListServlet")
public class PowerBatteryListServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=UTF-8");


       SqlSession sqlSession = MyBatisUtil.createSqlSession();
       List<Powerbattery> list = sqlSession.getMapper(SysPowerbatteryMapper.class).info();

        request.setAttribute("list",list);


        request.getRequestDispatcher("powerbatteryList.jsp").forward(request,response);
        MyBatisUtil.createSqlSession();

    }
}
